package weifei.wx.community.interceptor;


import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.HandlerInterceptor;
import weifei.web.Result;

public class WXTestInterceptor implements HandlerInterceptor
{
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception
    {
        var ip = request.getRemoteAddr();
        System.out.print("request ip: ");
        System.out.println(ip);

        if (
            ip.equals("106.55.202.118") ||
            ip.equals("113.96.223.69") ||
            ip.equals("125.39.132.125")
        )
        {
            response.setContentType("application/json");
            var out = response.getWriter();
            out.println(Result.success());
            return false;
        }

        return true;
    }
}

